The present invention relates to the field of computer graphics and, more particularly, to associating a pixel with one of a plurality of regions for evaluating the pixel light values.
Rendering of realistic images is one of the main goals of graphics system designers. Rendering images of real or imaginary objects typically involves generating geometric models (e.g., polygons) of the objects and applying lighting effects to the polygonal surfaces. In computer graphics, surfaces of an object are often modeled by a polygonal mesh, which is a collection of vertices, edges, and/or polygons. A mesh of polygons may be produced from a variety of sources such as an application, tesselated NURBS surfaces, spheres, cones, etc. The vertices may be connected by edges and a sequence of edges or vertices may define one or more polygons.
Rendering of realistic 3D graphics requires accurate and efficient modeling of 3D surfaces based upon the position, orientation, and characteristics of the surfaces and the light sources illuminating them. In particular, the interaction between lights and surfaces must be modeled for rendering. To accurately model lighting effects, conventional computer graphics systems have typically implemented a variety of lighting models and shading techniques to generate light values at individual pixels of a graphics primitive such as a polygon. A co-pending U.S. patent application Ser. No. 09/265507 and entitled "Method and Device for Generating Per-Pixel Values," by inventor David Tannenbaum et al., describes several exemplary lighting models and shading techniques.
Conventional lighting models typically model one or more lighting effects such as ambient light, diffuse reflection, specular reflection, and spotlighting, each of which is well known in the art. The ambient light accounts for a lighting effect resulting from multiple reflections of light from the surfaces present in a scene. On the other hand, the diffuse reflection models reflection of light off a dull, matte surface. In this model, the reflected light from the surface falls off uniformly as a function of the angle between N and L, where N is the outward normal vector at a surface point and L is a light vector. The light vector L has a direction from the surface point to a light source. The diffuse light fall-off in the diffuse reflection model is typically modeled by using a dot product term N.multidot.L.
Similarly, the specular reflection accounts for reflection of light off a shiny surface. When light from a light source is reflected off a surface, the reflected light is typically modeled as falling off exponentially from the direction of reflection vector R as seen from the direction of view vector V. For example, the fall-off may be modeled by cos.sup.s.alpha., where s is a surface material's specular-reflection coefficient and a is an angle between vectors R and V. In practice, a dot product term (N.multidot.H).sup.s is often used in place of cos.sup.s.alpha. to model specular reflection at a surface point, where N is a normal vector and H is a half-angle vector. Both the diffuse and specular reflection models assume that a light source radiates light uniformly in all directions.
The spotlight model, on the other hand, adds a direction to a positional light source to allow modeling of directional lights. That is, a spotlight is a special type of local or infinite light source that has a direction as well as a position. For example, a positional light source may function as a spotlight by restricting the shape of the light to exist within a cone. The direction of the spotlight is the direction in which the light points. The spotlight thereby simulates a cone of light, which may have a fall-off in intensity based upon distance from the center of the cone of light.
The spotlight and other conventional lighting models are described in Computer Graphics: Principles and Practice by James D. Foley et al., Addison-Wesley (1996), ISBN 0-201-84840-6, which is incorporated herein by reference and constitutes a portion of the background against which the present invention was developed. Additionally, the OpenGL.TM. (versions 1.1 and 1.2) graphics application programming interface, which is commercially available from Silicon Graphics, Inc., the assignee of the present application, describes various lighting models such as spotlight, diffuse light reflection, specular light reflection, and related parameters for implementing such models. The OpenGL.TM. (versions 1.1 and 1.2) graphics application programming interface also is incorporated herein by reference.
FIG. 1A illustrates a perspective view of a conventional spotlight 100 being radiated from a light source 102 onto a surface 104. In this configuration, the light source 102 radiates the spotlight 100 in a cone shape that is defined by edge 108 of the cone and a center axis 106 of the cone. The angle between the center axis 106 and the edge 108 of the cone defines a cutoff angle .phi.. The cutoff angle .phi. defines a boundary 110 of the spotlight 100. That is, the spotlight value is set to zero in an outer region 114 lying outside of the boundary 110. In an inner region 112 of the boundary 110, the spotlight value is computed in accordance with a basic spotlight equation, spotlight=(S.multidot.L).sup.exp, where S represents a spotlight source direction vector, L represents the vector from a point on the surface to the light source, and exp is a spotlight exponent. The spotlight equation may also include other well-known variables such as attenuation, shadow, etc.
FIG. 1B shows a vector diagram 150 depicting the relationship between the light source direction vector S and spotlight vector L of the spotlight equation at an arbitrary point P on a surface 152. The vector S represents the direction of light from the light source 102. The anti-parallel vector -L, on the other hand, represents the direction from the spotlight to point P. By definition, the vector L has the same magnitude but opposite direction as its anti-parallel vector, -L. The angle between the vectors S and -L is designated as angle .theta..
Unfortunately, conventional spotlighting techniques using the spotlight equation often exhibit aliasing effects such as jaggies or stairsteps near the boundary of the cutoff angle (e.g., boundary 110 in FIG. 1A). These aliasing effects are caused by the abrupt transition into the cutoff region where the light values are zero. In other words, the transition from the lighted cone area to the outer region is not smooth because the light contribution from a light source is applied in an all-or-nothing fashion based on the relationship of point P with respect to the lighted cone's projection on the surface 104 or 152.
To reduce the aliasing effects, a conventional method provided a transition region between an inner, lighted region and an outer, dark region. FIG. 1C illustrates a perspective view of a spotlight 170 being radiated from a light source 102 onto a surface 176. The light source 102 radiates the spotlight 170 in a cone shape having an angle .phi., which is the angle between the edge 172 of the cone and the center axis 174 of the cone. This method provides three regions: an inner region 178, a transition region 180, and an outer region 182. The inner and transition regions 178 and 180 are defined with respect to an inner boundary 184. The transition and outer regions 180 and 182 are defined with respect to an outer boundary 186 defined by the cutoff angle .phi..
In this arrangement, the light values in the inner region 178 are computed in accordance with a spotlight equation while the light values in the outer region are set to zero. The light values in the transition region, on the other hand, are computed to provide a gradual fall-off in intensity. The gradual intensity fall-off in the transition region thereby reduces aliasing effects.
One of the drawbacks in implementing the conventional approaches in a computer system is the complexity and cost. For example, determining in which region a pixel falls requires computing a dot product (S.multidot.-L) raised to a spotlight exponent and performing complex comparisons involving cosine and arccosine of angles such as cutoff .phi., the angle between S and -L, etc. The computation of the dot product along with the evaluation of cosines and arccosines typically requires expensive and complex computer systems.
Thus, what is needed is a method and device that can efficiently determine in which region a pixel belongs for determining spotlight values without substantial cost and complexity.